<html>
<head><meta charset="utf-8"><title>Odd path resolution behaviour in attributes · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html">Odd path resolution behaviour in attributes</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="244167605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244167605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244167605">(Jun 28 2021 at 16:04)</a>:</h4>
<p>I just realized that hovering <code>query_group</code> in <code>#[salsa::query_group(...)]</code> does not show a hover info, even though it should, and fixing up a small test like:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[proc_macro_attribute]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">proc</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="c1">//- /main.rs crate:main deps:foo</span>
<span class="cp">#[foo::foo$0]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">X</span><span class="p">;</span><span class="w"></span>

<span class="c1">//- /foo.rs crate:foo</span>
<span class="cp">#[proc_macro_attribute]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>does in fact give me the correct hover here. Any clues whats going on here?</p>



<a name="244167683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244167683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244167683">(Jun 28 2021 at 16:04)</a>:</h4>
<p>I checked the item tree of the salsa definition file for the proc macro and the proc macro still has its <code>proc_macro_attribute</code> attribute in there so it should work fine</p>



<a name="244167732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244167732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244167732">(Jun 28 2021 at 16:05)</a>:</h4>
<p>Implementation Note: When resolving a path in an attribute we check that the function that is described by the path has a <code>proc_macro_attribute</code> attribute, if it doesnt we refuse to resolve it.</p>



<a name="244167928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244167928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244167928">(Jun 28 2021 at 16:07)</a>:</h4>
<p>Also the attribute expansion config seems to be irrelevant to this.</p>



<a name="244168206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244168206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244168206">(Jun 28 2021 at 16:09)</a>:</h4>
<p>yeah, we've resolved these before we could expand them</p>



<a name="244168238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244168238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244168238">(Jun 28 2021 at 16:09)</a>:</h4>
<p>not sure what the issue is though, I haven't touched that code</p>



<a name="244168769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244168769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244168769">(Jun 28 2021 at 16:14)</a>:</h4>
<p>Interesting, so I changed the logic so that you can also hover the path prefixes and now hovering <code>salsa</code> gives me the crate docs. So we are somehow losing the proc_macro_attribute attribute on the function it seems</p>



<a name="244168868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244168868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244168868">(Jun 28 2021 at 16:14)</a>:</h4>
<p>which seems odd since the item tree has it according to debug view <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="244170379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244170379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244170379">(Jun 28 2021 at 16:26)</a>:</h4>
<p>Oh wait I see whats going on</p>



<a name="244170449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244170449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244170449">(Jun 28 2021 at 16:27)</a>:</h4>
<p>We arent resolving those to functions anymore, but to macros so the trick now just discards it always <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="244175484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Odd%20path%20resolution%20behaviour%20in%20attributes/near/244175484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Odd.20path.20resolution.20behaviour.20in.20attributes.html#244175484">(Jun 28 2021 at 17:06)</a>:</h4>
<p><a href="/user_uploads/4715/r7PlfGS5LjG8gPhe0f5fMeSP/image.png">image.png</a> <br>
There we go, <del>for some reason docs are missing though</del> attr_query is skipping proc-macros so no docs</p>
<div class="message_inline_image"><a href="/user_uploads/4715/r7PlfGS5LjG8gPhe0f5fMeSP/image.png" title="image.png"><img src="/user_uploads/4715/r7PlfGS5LjG8gPhe0f5fMeSP/image.png"></a></div>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>